package com.baoji.auth.model;

/**
 * @Auther: ghm
 * @Date: 2021/09/26/18:27
 * @Description:
 */
public enum AccountErrorCode {

    USERNAME_ERROR(1001, "用户名已存在"),
    USER_NOT_REGISTER(1002, "用户未注册"),
    USERNAME_ISNONULL(1003,"用户名不能为空"),
    PASSWORD_ISNONULL(1004,"密码不能为空"),
    USERNAME_PASSWORD_ERROR(1005, "用户名或密码错误"),
    REGISTER_ERROR(1006, "注册失败"),
    GET_VERIFY_ERROR(1007, "获取短信验证码失败"),
    VERIFY_CODE_ERROR(1008, "验证码错误"),
    ACCOUNT_DISABLED(1009, "该账户已被禁用，请联系管理员"),
    ACCOUNT_LOCKED(1010, "该账号已被锁定，请联系管理员"),
    ACCOUNT_EXPIRED(1011, "该账号已过期，请联系管理员"),
    CREDENTIALS_EXPIRED(1012, "该账户暂无登录凭证，请登录"),
    TOKEN_EXPIRED_ERROR(1013,"token过期了，refresh token 不是我们系统签发的");

    private int code;
    private String message;


    public int getCode() {
        return code;
    }


    public String getMessage() {
        return message;
    }

     AccountErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static AccountErrorCode parse(int code) {
        AccountErrorCode[] values = values();
        for (AccountErrorCode value : values) {
            if (value.getCode() == code) {
                return value;
            }
        }
        throw new RuntimeException("Unknown code of AccountErroCode");
    }
}
